<template>
  <ex-dialog
    width="50%"
    class="ex-diolog"
    title="提现审核"
    :visible="visible"
    @closeDialog="handleClose"
    center
  >
    <el-dialog
      width="30%"
      title="提现审核"
      :visible.sync="innerVisible"
      append-to-body
      center
    >
      <div class="refuseMain">
        <div class="txt">请选择拒绝原因：</div>
        <el-radio-group v-model="radio" @change="change">
          <el-radio :label="1">今日提现太频繁，请明日重试！</el-radio>
          <el-radio :label="2">账户余额不足，请联系平台商户！</el-radio>
          <el-radio :label="3">其他</el-radio>
        </el-radio-group>
        <el-input
          v-if="radio==3"
          type="textarea"
          :rows="3"
          placeholder="请输入内容"
          v-model="textarea"
          maxlength="20"
          show-word-limit
          @blur = "changetxt"
        >
        </el-input>
        <div class="buttom">
          <el-button size="medium" @click="innerVisible = false"
            >返回</el-button
          >
          <el-button size="medium" type="primary" @click="confirmRejection"
            >确认</el-button
          >
        </div>
      </div>
    </el-dialog>
    <div class="main">
      <loading v-if="loading" />
      <text-list v-else label-width="200px" :column="1">
        <!-- common info -->
        <text-item label="申请时间：">{{ data.createTime }}</text-item>
        <text-item label="类型：">用户提现</text-item>
        <text-item label="账号名称：">{{ data.wecharName }}</text-item>
        <text-item label="申请提现金额（¥）：">{{
          data.withdrawMoney
        }}</text-item>
        <text-item label="打款方式：">{{ data.payTypeDict }}</text-item>
        <!-- <text-item label="本周已提现金额：">{{ data.weekMoney }}</text-item> -->
        <text-item label="累计提现次数（次）">{{ data.withdrawNum }}</text-item>
      </text-list>
    </div>

    <template slot="footer">
      <el-button type="danger" @click="rejectClick">拒绝</el-button>
      <el-button type="primary" @click="agreeClick">同意</el-button>
    </template>
  </ex-dialog>
</template>
<script>
// components
import { auditDetail, manualAgreeCustomer, manualRejectCustomer,manageCustomer } from "@/api/moneyManagement";
import Loading from "@/components/Loading/index";
export default {
  components: {
    Loading,
  },
  props: {
    visible: Boolean,
    id: String,
  },
  data() {
    return {
      loading: false,
      data: {},
      applyDetail: {},
      radio: 1,
      remark: "",
      innerVisible: false,
      textarea: "",
      remark:'今日提现太频繁，请明日重试！'
    };
  },
  // computed: {
  //   industryTypeText() {
  //     return this.applyDetail.type
  //       ? this.$getStatusText('industry_type', this.applyDetail.type)
  //       : ''
  //   }
  // },
  created() {
    this.getDetail();
  },
  methods: {
    getDetail() {
      console.log(this.id);
      // const params = {
      //   id: this.id,
      // };
      this.loading = true;
      manageCustomer(this.id)
        .then((res) => {
          console.log("获取详情", res);
          const { result } = res;
          // result.statusText = this.$getStatusText('quality_cert_verify_status', result.status)
          this.data = result;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    handleClose() {
      this.$emit("update:visible", false);
    },

    handleSuccess(msg) {
      this.$message({
        message: msg,
        type: "success",
        duration: 1500,
        onClose: () => {
          this.handleClose();
          this.$emit("success");
        },
      });
    },

    rejectClick() {
      this.innerVisible = true;
    },

    confirmRejection() {
      if(this.radio==3&&this.textarea==''){
        this.$message.error('请填写拒绝原因');
        return
      }
      var params = {
        id: this.id,
        remark: this.remark,
      };
      manualRejectCustomer(params).then((res) => {
        this.handleSuccess("已拒绝");
      });
    },
    agreeClick() {
      this.$confirm("是否同意?", "提示", {
        confirmButtonText: "是",
        cancelButtonText: "否",
        type: "warning",
      })
        .then(() => {
          var data = {
						id: this.id,
					}
          manualAgreeCustomer(data).then(res => {
            this.handleSuccess('已同意')
          })
        })
        .catch();
    },
    changetxt(event){
      console.log(this.textarea)
      this.remark = this.textarea
    },
    change(e) {
      console.log(e);
      if(e==1){
        this.remark = '今日提现太频繁，请明日重试！'
      }else if(e==2){
        this.remark = '账户余额不足，请联系平台商户！'
      }else{
        this.remark = this.textarea
      }
    },
  },
};
</script>
<style lang="scss" scoped>
.buttom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 150px;
  margin-top: 30px;
}
.txt {
  font-size: 15px;
  margin-bottom: 20px;
}
.refuseMain {
  ::v-deep .el-radio-group {
    display: flex !important;
    flex-direction: column !important;
  }
  .el-radio {
    margin-bottom: 15px !important;
    margin-left: 20px !important;
  }
  .el-input--medium {
    font-size: 14px;
    margin-left: 44px;
  }
  .el-textarea {
    width: 90%;
  }
}
.ex-diolog {
  ::v-deep .ex--dialog--footer {
    border: none !important;
  }

  .main {
    margin: 0 auto;
  }
  .pic-list {
    display: flex;
    justify-content: space-around;
    width: 660px;
  }
  .img {
    display: block;
    width: 200px;
    height: auto;
  }
}
</style>
